package com.stbu.controller;

import com.stbu.controller.bean.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Date;

@Controller
@RequestMapping("/user")
public class UserController {

    @RequestMapping("/toReg")
    public String toReg() {
        return "reg";
    }
//    执行注册功能
    @RequestMapping("/reg")
    public String reg(@RequestParam("username") String u, @RequestParam("pwd") String pwd,
                      Model model){
        Date regDate = new Date();
        User user = new User();
        user.setUsername(u);
        user.setPassword(pwd);
        model.addAttribute("regDate",regDate);
        model.addAttribute("user",user);
        return "forward:toLogin";

    }

    @RequestMapping("/toLogin1")
    public String toLogin() {
        return "login";
    }

}
